#include "stdio.h"
#include "string.h"
#include "Daemon_BoardVersion.h"

static unsigned char a2Version = VERSION_DEFAULT;

int VersionCheck(void)
{   
    static char verdata[64];
    int iRet = 0;
    FILE *fpVer = NULL;

	a2Version = VERSION_A2_NORMAL;

	return 0;

    fpVer = fopen("/etc/version", "r");
    if (NULL == fpVer) 
    {
        _printd ( "open ver file error\n");
        return -1;
    }
    iRet = fscanf(fpVer, "%s", verdata);    
    if (iRet <= 0) 
    {
        _printd ( "fscanf return var <= 0 \n");
        fclose(fpVer);
        return -1;
    }
    if (strstr(verdata,"Ruishi"))
    {        
        a2Version = VERSION_A2_RUISHI;
        _printd("Day & Night for Ruishi version !!! (%d) \n",a2Version);
        fclose(fpVer);
        return 0;
    }
    else if (strstr(verdata,"DayNight"))
    {
        a2Version = VERSION_A2_DAYNIGHT;
        _printd("Day & Night version !!! (%d) \n",a2Version);
        fclose(fpVer);
        return 0;
    }
    else if (strstr(verdata,"HI3518E_V200"))
    {
        a2Version = VERSION_A2_NORMAL;
        _printd("Normal version !!! (%d)  \n",a2Version);
        fclose(fpVer);
        return 0;
    }
    else
    {
         _printd("Invalid version !!! (%d)  \n",a2Version);
         return -1;
    }
}

int GetVersion(void)
{
	if(a2Version == VERSION_DEFAULT)
		VersionCheck();
	
    return a2Version;
}
